package cn.edu.buaa.cnsatm.traffic_big_data_server.highway.controller;

import cn.edu.buaa.cnsatm.traffic_big_data_server.highway.model.ImageService;
import cn.edu.buaa.cnsatm.traffic_big_data_server.highway.service.HighwayCongestionService;
import cn.edu.buaa.cnsatm.traffic_big_data_server.waterway.service.SeaStatusService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLException;
import java.text.ParseException;

@RestController
public class HighwayController {
    /**
     * @author LX
     * @return 见接口文档
     * @description 返回拥挤度前k的公路
     * @since 2019-10-19
     */
    @RequestMapping("/highwayCongestion")
    @ResponseBody
    public String webTopKWaveHeight(
            @RequestParam(value = "top_num",required = true,defaultValue = "8") Integer k
    ) throws SQLException {
        //System.out.println("hello");
        return HighwayCongestionService.getTopKCongestHighwayFromDatabase(k);
    }

    @RequestMapping("/highwayWeatherImage")
    @ResponseBody
    public String webGetLatestRoadWeatherImage(
    ) throws SQLException {
        /**
         * @author LX
         * @return 见接口文档
         * @description 返回最新的公路天气图
         * @since 2019-10-29
         */
        //System.out.println("hello");
        return ImageService.getNewestImageByImageType("road");
    }

    @RequestMapping("/highwayLocation")
    @ResponseBody
    public String webGetHighwayLocation(
    ) throws SQLException {
        /**
         * @author LX
         * @return 见接口文档
         * @description 返回公路位置
         * @since 2019-12-2
         */
        return HighwayCongestionService.getAllHighwayLocationFromDatabase();
    }
    @RequestMapping("/highwayCongestionMap")
    @ResponseBody
    public String webGetHighwayCongestionMap(
            @RequestParam(value = "min_congest", required = false, defaultValue = "0") double ignoreValue
    ) throws SQLException, ParseException {
        /**
         * @author LX
         * @return 见接口文档
         * @description 返回拥挤的路段位置，现在只返回一个点
         * @since 2019-12-2
         */
        return HighwayCongestionService.getHighwayCongestPointFromWeb();
        //return HighwayCongestionService.getHighwayCongestionMap(ignoreValue);
    }
}
